<template>
  <div class="app-scheduling" style="margin: 0 !important;">
    <el-form :model="productionQuery" :rules="productionrules" ref="productionQuery" label-width="90px" class="demo-ruleForm"
      style="margin-top: 20px;">
      <el-col class="productionCommon productionCommonCopy">
        <el-form-item label="后台单号">
          <el-input v-model.trim="productionQuery.xmbzNo" clearable placeholder="后台单号" size="small" style="width: 180px;"></el-input>
        </el-form-item>
        <el-form-item label="总仓" label-width="55px">
          <el-select ref="mainWarehouseRef" v-model="productionQuery.mainWarehouse"  placeholder="总仓" size="small" @change="getmainWarehouseIds"
            style="width: 100px;" @keydown.native="selectBlur($event)">
            <el-option v-for="(mainWareHouse,index) in getMainWarehouseList" :key="index" :label="mainWareHouse.deptName"
              :value="{value:mainWareHouse.id,label:mainWareHouse.deptName}">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="分仓" label-width="55px" class="branchWareHouse">
          <el-select ref="barnchWarehousesRef" v-model="barnchWarehousesName"  placeholder="分仓" size="small" style="width: 90px;"
            class="branchWareHouse" @change="getbarnchWarehouses" @keydown.native="selectBlur($event)">
         <!--   <el-option v-for="(SeparateWarehouseList,index) in getSeparateWarehouseList" :key="index" :label="SeparateWarehouseList.name"
              :value="SeparateWarehouseList.id" class="branchWareHouse">
              <span :data-id="SeparateWarehouseList.id" style="display: inline-block;width: 80px;padding: 0 20px;margin-left: -20px;"
                @click="getwarehouseId($event)">{{ SeparateWarehouseList.name }}</span>
            </el-option> -->
            <el-option v-for="item in getSeparateWarehouseList" :key="item.id" :label="item.name" :value="{label:item.name,value:item.id}" />
            <!-- <el-option v-for="(house,ware) in abbrlist" :key="ware" :label="house.name" :value="house.name"></el-option> -->
          </el-select>
        </el-form-item>
        <el-form-item label="蛋糕状态" label-width="79px">
          <el-select ref="statusRef" v-model="productionQuery.status" placeholder="全部" size="small" style="width: 100px;" @keydown.native="selectBlur($event)">
            <el-option v-for="item in statusList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
          </el-select>
        </el-form-item>
        <el-form-item label="打印状态" label-width="79px">
          <el-select ref="printingRef" v-model="productionQuery.printingState" placeholder="全部" size="small" style="width: 100px;" @keydown.native="selectBlur($event)">
            <el-option v-for="item in printingStateList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
          </el-select>
        </el-form-item>
        <el-form-item label="配送时间">
          <el-form-item style="display: flex;">
            <el-date-picker
              v-model="timeValue"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              :picker-options="pickerOptions"
              value-format="yyyy-MM-dd HH:mm"
              :default-time="['00:00:00', '23:59:59']"
              format="yyyy-MM-dd HH:mm"
              :clearable="false"
              size="small"
              @change="changeTime"
              align="right">
            </el-date-picker>
            <!-- <el-date-picker v-model="productionQuery.deliveryStartTime" type="datetime" placeholder="请选择配送时间" align="right"
              value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions" clearable size="small" style="width: 199px;"></el-date-picker>
            <span class="line" align="center" style="display: inline-block;font-size: 20px;text-align: center;color: #C0C4CC;">-</span>
            <el-date-picker v-model="productionQuery.deliveryEndTime" type="datetime" placeholder="请选择配送时间" align="right"
              value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions" clearable size="small" style="width: 199px;"></el-date-picker> -->
          </el-form-item>
        </el-form-item>
        <!-- <el-col class="productionCommon" style="height: 60px;width: 100%;"> -->
        <!-- <el-form-item label="产品类别">
        <el-input v-model="productionQuery.productionKind" placeholder="产品类别" size="small" style="width: 100px;"></el-input>
      </el-form-item> -->
        <el-form-item label="产品名称">
          <el-autocomplete
            id="goodsNameRef"
            ref="goodsNameRef"
            v-model="productionQuery.goodsName"
            :fetch-suggestions="querySearch"
            placeholder="产品名称"
            size="small"
          ></el-autocomplete>
          <!-- <el-select ref="goodsNameRef" id="goodsNameRef" v-model="productionQuery.goodsName" filterable placeholder="请选择" clearable @keydown.native="keydown($event)">
            <el-option
              v-for="(item,index) in tradeNameRecord"
              :key="index"
              :label="item"
              :value="item">
            </el-option>
          </el-select> -->
          <!-- <el-input v-model.trim="productionQuery.goodsName" clearable placeholder="产品名称" size="small" style="width: 100px;"></el-input> -->
        </el-form-item>
        <el-form-item label="规格">
          <el-input v-model.trim="productionQuery.goodsSpecs" clearable placeholder="产品磅数" size="small" style="width: 100px;"></el-input>
        </el-form-item>
        <el-form-item label-width="20px">
          <el-button icon="el-icon-search" type="primary" size="small" plain @click="submitForm('productionQuery')">查询</el-button>
        </el-form-item>
        <el-form-item label-width="10px" style="margin-top: -4px;">
          <el-checkbox v-model="clickFramingchecked" label="开启自动刷单" border size="small" @change="clickFraming"></el-checkbox>
          <!-- <el-checkbox v-model="clickFramingchecked" border size="small"><span @click="clickFraming">开启自动刷单</span></el-checkbox> -->
        </el-form-item>
        <el-col style="margin-left: 20px;width: 90px;display: flex;flex-direction: column;align-items: center;">
          <el-button type="danger" size="small" @click="closeOrder" onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;}">关闭接单</el-button>
          <!-- <span v-if="closeOrderFlag" class="CoummonFlag">请先勾选蛋糕</span> -->
        </el-col>
        <el-col style="margin-left: 20px;width: 120px;">
          <el-button type="danger" plain size="small" @click="closeOrderListOpen" onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;}">接单关闭列表</el-button>
        </el-col>
        <!-- <el-col style="margin-left: 20px;width: 120px;">
          <el-button type="primary" size="small" @click="cookieStamp($event)">打印曲奇</el-button>
        </el-col> -->
        <el-form-item label-width="10px" style="margin-top: -4px;">
          <el-checkbox v-model="labelchecked" label="是否打印祝福语标签纸" border size="small"></el-checkbox>
          <!-- <el-checkbox v-model="clickFramingchecked" border size="small"><span @click="clickFraming">开启自动刷单</span></el-checkbox> -->
        </el-form-item>
        <!-- <el-form-item label="商品名称" style="margin-top: -4px;">
          <el-select v-model="tradeName" filterable placeholder="请选择">
            <el-option
              v-for="(item,index) in tradeNameRecord"
              :key="index"
              :label="item"
              :value="item">
            </el-option>
          </el-select>
        </el-form-item> -->
      </el-col>
      <!-- </el-col> -->
    </el-form>
    <!-- <div style="position: fixed;top: -100%;right: -100%;">
      <CookieTemplate ref="CookieTemplate" id="CookieTemplate" v-bind:CookieTemplateList="CookieTemplateList" v-bind:getNowTime="getNowTime" style="width: 350px;height: 150px;"></CookieTemplate>
    </div> -->
    <!-- 批量打印 -->
    <div style="position: fixed;top: -100%;right: -100%;height: 350px;">
      <Printform v-if="labelchecked == false ? true : false" ref="Printform" v-bind:orderGoodriesList="StampStorageReturnList" id="Printform" style="width: 350px;"></Printform>
      <LabelPrint v-if="labelchecked == true ? true : false" ref="Printform" v-bind:orderGoodriesList="StampStorageReturnList" id="Printform" style="width: 350px;"></LabelPrint>
      <!-- <div id="printing" style="width: 350px;" class="ordermain">
      <div v-for="(item,index) in StampStorageReturnList" :key="index" style="width: 350px;height: 360px;">
        <div style="display: flex;">
          <div>
            <p style="line-height: 1">
              <span>品名：{{item.goodsName}}</span>
            </p>
            <p>后台单号：{{ item.orderId }}</p>
            <p style="display: flex;justify-content: space-between;width: 80%">
              <span>配送区域：{{ item.branchWarehouse }}</span>
              <span>净含量：500g</span>
            </p>
          </div>
          <div>
            <img :src="item.warehousingCode" alt="" style="width: 100px;height: 100px;">
          </div>
        </div>
        <p>配送时间：{{ item.deliveryStartTime }}~{{ item.deliveryEndTime }}</p>
        <p>配送地址：{{ item.receiverAddress}}</p>
        <p>
          <span>订单来源：饿了么</span>
          <span>祝福语：豆豆三岁生日快乐</span>
        </p>
        <p style="display: flex;justify-content: space-between;">
          <span>配料：</span>
          <span>保质期：冰箱冷藏，最晚不超过4小时</span>
        </p>
        <p>储藏方式：0℃ ~ 5℃常温放置请勿超过30分钟</p>
      </div>
    </div> -->
    </div>
    <!-- 批量生产、打印、入库 -->
    <el-col class="productionCommon">
      <div style="width: 35%;height: 80px;margin-left: 40px;">
        <el-col :span="7" style="display: flex;flex-direction: column;align-items: center;">
          <el-button type="primary" size="small" @click="volumnProduction" class="production-button" onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;}">批量生产</el-button>
          <!-- <span v-if="productionCakeFlag" class="CoummonFlag">请先勾选蛋糕</span> -->
        </el-col>
        <el-col :span="7" style="display: flex;flex-direction: column;align-items: center;">
          <el-button type="primary" size="small" @click="volumnStamp" class="production-button" onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;}">批量打印</el-button>
          <!-- <span v-if="volumnStampFlag" class="CoummonFlag">请先勾选蛋糕</span> -->
        </el-col>
        <el-col :span="7" style="display: flex;flex-direction: column;align-items: center;">
          <el-button type="primary" size="small" @click="volumnNormalOrder" class="production-button" onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;}">异常订单</el-button>
        </el-col>
        <!-- <el-col :span="7" style="display: flex;flex-direction: column;align-items: center;">
        <el-button type="primary" size="small" @click="volumnStorage" class="production-button">异常订单</el-button>
        <span v-if="volumnStorageFlag" class="CoummonFlag">请先勾选蛋糕</span>
      </el-col> -->
        <el-dialog :visible.sync="productionStampFlag" center :append-to-body="true" :lock-scroll="false" width="35%"
          z-index="2007">
          <div style="width: 100%;">
            <el-scrollbar class="page-component__scroll">
              <!-- <div v-if="productionStartFlag" style="height: 200px;">
                <el-col style="margin-top: 1%;">
                  <div class="order-message" style="height: 35px;">
                    <el-col style="padding-left: 5px;font-size: 20px;">
                      批量生产
                    </el-col>
                  </div>
                  <div style="height: 300px;margin-left: 25px;">
                    <el-form :model="startruleForm" :rules="startrules" ref="startruleForm" label-width="100px" class="demo-ruleForm">
                      <el-form-item label="制作人" prop="producer">
                        <el-input v-model="startruleForm.producer" placeholder="请输入制作人" maxlength="10" style="width: 200px;"></el-input>
                      </el-form-item>
                      <el-form-item label="裱花人" prop="carver">
                        <el-input v-model="startruleForm.carver" placeholder="请输入裱花人" maxlength="10" style="width: 200px;"></el-input>
                      </el-form-item>
                      <el-form-item label="打包人" prop="packer">
                        <el-input v-model="startruleForm.packer" placeholder="请输入打包人" maxlength="10" style="width: 200px;"></el-input>
                      </el-form-item>
                      <el-form-item>
                        <el-button @click="startResetForm('startruleForm')">取消</el-button>
                        <el-button type="primary" @click="startSubmitForm('startruleForm')">确定</el-button>
                      </el-form-item>
                    </el-form>
                  </div>
                </el-col>
              </div> -->
              <div v-if="productionStampFlag" style="height: 100px;">
                <el-col style="margin-top: 1%;">
                  <div style="width: 100%;">
                    <el-form :model="StampruleForm" ref="StampruleForm" label-width="100px" class="demo-ruleForm">
                      <div style="font-size: 17px;margin-left: 5px;">
                        是否决定批量打印{{ StampStorageList.length }}张？
                      </div>
                      <el-form-item style="margin-top: 7%;display: flex;justify-content: flex-end;">
                        <el-button @click="StampResetForm()">取消</el-button>
                        <el-button type="primary" data @click="StampSubmitForm($event,'StampruleForm')">确定</el-button>
                      </el-form-item>
                    </el-form>
                  </div>
                </el-col>
              </div>
            </el-scrollbar>
          </div>
        </el-dialog>
      </div>
      <div style="width: 65%;height: 80px;" class="statistics">
        <div class="production-bigbutton primary">
          <el-col class="production-message">今日待生产</el-col>
          <el-col class="production-number">{{ getProductionOrderSummaryList.stayProductionNum }}个</el-col>
        </div>
        <div class="production-bigbutton success">
          <el-col class="production-message">今日生产中</el-col>
          <el-col class="production-number">{{ getProductionOrderSummaryList.startProductionNum }}个</el-col>
        </div>
        <div class="production-bigbutton infostatistics">
          <el-col class="production-message">今日已入库</el-col>
          <el-col class="production-number">{{ getProductionOrderSummaryList.warehousingNum }}个</el-col>
        </div>
      </div>
    </el-col>
    <!-- 获取批量入库异常与否弹框 -->
    <el-dialog :visible.sync="abnormalOrderFlag" center :append-to-body="true" :lock-scroll="false" width="90%" z-index="2007">
      <!-- <div style="width: 100%;height: 680px;"> -->
      <div style="width: 100%;">
        <!-- <el-form v-model="getNotReadOrderNewsLogList" label-width="100px" class="demo-ruleForm">
          <div>
            <span style="font-size: 17px;margin-left: 5px;color: red;">
              存在{{ total }}个蛋糕异常
            </span>
          </div> -->
        <div class="tablist">
          <span class="name" v-for="(item,index) in tabs" :class="{active:(indexs==index)}" @click="handleTabs(index)"
            :key="index">{{item.name}}</span>
        </div>
        <!-- <el-scrollbar class="page-component__scroll" style="min-height: 250px;"> -->
        <div v-if="indexs==0">
          <el-table :data="getNotReadOrderNewsLogList" style="width: 100%" border>
            <el-table-column prop="goodsName" align="center" width="180" label="蛋糕名称" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="goodsSpecs" align="center" width="180" label="规格" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="regionName" align="center" width="90" label="地区" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="warehouseName" align="center" width="90" label="仓库" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="xmbzNo" align="center" width="180" label="后台单号" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="remarks" align="center" width="90" label="备注" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="printingState" label="打印状态" align="center" width="100">
              <template slot-scope="{row}">
                <span v-if='row.printingState==1'>未打印</span>
                <span v-if='row.printingState==2'>已打印</span>
              </template>
            </el-table-column>
            <el-table-column prop="newsTypeName" align="center" width="90" label="目前进度">
            </el-table-column>
            <el-table-column align="center" label="操作">
              <template slot-scope="scope">
                <el-button v-show="scope.row.newsType == 2 && scope.row.productionProcess == 6" v-for="(itemProcess) in getProductionProcessList"
                  :key="itemProcess.dictKey" plain size="mini" @click="productionSelect(scope.$index, scope.row, itemProcess.dictKey)">{{ itemProcess.dictValue }}</el-button>
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total>0" :total="total" :page.sync="getNotReadOrderNewsLogQuery.page" :limit.sync="getNotReadOrderNewsLogQuery.size"
            @pagination="getAbnormalList" />
        </div>
        <div v-if='indexs==1'>
          <el-form :inline="true" :model="AbnormalrecordListQuery" class="demo-form-inline Abnormalrecord-inline">
            <el-form-item>
              <el-date-picker v-model="Time" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" size='small'
                :default-time="['00:00:00', '23:59:59']">
              </el-date-picker>
            </el-form-item>
            <el-button type="primary" plain size="small" icon="el-icon-search" @click="handleFilter(Time)">查询</el-button>
          </el-form>
          <el-table :data="getAbnormalrecordList" style="width: 100%" border>
            <el-table-column prop="goodsName" align="center" width="180" label="蛋糕名称" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="goodsSpecs" align="center" width="180" label="规格" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="regionName" align="center" width="90" label="地区" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="warehouseName" align="center" width="90" label="仓库" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="xmbzNo" align="center" width="180" label="后台单号" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="remarks" align="center" width="90" label="备注" :show-overflow-tooltip="true">
            </el-table-column>
           <el-table-column prop="printingState" label="打印状态" align="center" width="100">
             <template slot-scope="{row}">
               <span v-if='row.printingState==1'>未打印</span>
               <span v-if='row.printingState==2'>已打印</span>
             </template>
           </el-table-column>
            <el-table-column prop="productionProcessName" align="center" label="操作">
            </el-table-column>
          </el-table>
         <pagination v-show="Abnormalrecordtotal>0" :total="Abnormalrecordtotal" :page.sync="AbnormalrecordListQuery.page"
                    :limit.sync="AbnormalrecordListQuery.size" @pagination="getAbnormalrecordLists" />
        </div>

        <!-- </el-scrollbar> -->
        <!-- <el-form-item style="display: flex;justify-content: flex-end;"> -->
        <!-- <el-button @click="StorageRecordResetForm()">取消</el-button> -->
        <!-- <el-button type="primary" @click="StorageRecordSubmitForm()">确定</el-button> -->
        <!-- </el-form-item> -->
        <!-- </el-form> -->
      </div>
      <!-- </div> -->
    </el-dialog>
    <!-- 列表模块 -->
    <el-col style="margin-left: 40px;">
      <productionList :productionQuery="productionQuery" @getProductionNumber="getProductionNumber"
        :getProductionQueryPageList="getProductionQueryPageList" v-bind:isQueryFlag="isQueryFlag" v-bind:labelcheckedFlag="labelchecked" ref="procedureEdit"></productionList>
    </el-col>
    <!-- 接单关闭列表 -->
    <el-dialog :visible.sync="closeOrderListOpenFlag" center :append-to-body="true" :lock-scroll="false" width="75%"
      z-index="2007">
      <div style="width: 100%;">
        <div style="width: 100%;">
          <h3 style="text-align: center;">接单关闭列表</h3>
          <el-table ref="multipleTable" :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55 ">
            </el-table-column>
            <el-table-column prop="goodsName" label="蛋糕名称">
            </el-table-column>
            <el-table-column prop="specs" label="规格">
            </el-table-column>
            <el-table-column prop="regionName" label="地区">
            </el-table-column>
            <el-table-column prop="warehouseName" label="仓库">
            </el-table-column>
          </el-table>
          <pagination v-show="tableDatatotal>0" :total="tableDatatotal" :page.sync="getCloseOrderList.page"
            :limit.sync="getCloseOrderList.size" @pagination="closeOrderListOpen" />
          <div style="text-align: center;margin-top: 20px;">
            <el-button type="primary" @click="toggleSelectionOpen()">开启接单</el-button>
            <el-button @click="handletoggleSelectionOpen()" plain>取消</el-button>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {
    // citySelect,
    getMainWarehouseListByRoleIdAll, // 总仓
    getSeparateWarehouseListByRoleIdAll, // 分仓
  } from "@/api/createOrder";
  import {
    // getCakeProductionStateList, // 状态
    getProductionOrderSummary, // 今日生产数量汇总
    getProductionQueryPage, // 查询
    batchStartProduction, // 批量生产
    orderPrinting, // 批量打印
    orderPrintingFrequency,  // 批量打印信息
    getNotReadOrderNewsLog, // 退订改期异常记录
    closeOrder, // 关闭订单
    productionChoice, // 生产部生产流程选择
    refundChoice, // 生产部生产中退款流程选择
    getCloseOrderList, // 接单关闭订单列表
    getUpCloseOrder, // 开启接单
    confirmProductionToWarehousingLog,// 确认继续生产并入库记录
  } from '@/api/shop';
  import { query } from "@/api/user"; // 查询生产打印机设备
  import productionList from '@/components/production';
  import Printform from "@/components/Printform";
  import LabelPrint from "@/components/Printform/labelprint"; // 打印蛋糕模板
  import getLodop from '@/lodop/LodopFuncs';
  import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
  // import CookieTemplate from "@/components/Cookie-template"; // 打印曲奇模板
  export default {
    components: {
      productionList,
      Printform,
      LabelPrint,
      Pagination,
      // CookieTemplate
    },
    data() {
      var validatePass = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入制作人'));
        } else {
          this.startruleForm.producer = value.replace(/\s+/g, '');
          callback();
        }
      };
      var validatePass3 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入裱花人'));
        } else {
          this.startruleForm.carver = value.replace(/\s+/g, '');
          callback();
        }
      };
      var validatePass4 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入打包人'));
        } else {
          this.startruleForm.packer = value.replace(/\s+/g, '');
          callback();
        }
      };
      return {
        Time: [
          this.dayjs(
            new Date()
          )
          .format("YYYY-MM-DD 00:00:00")
          .toString(),
          this.dayjs(
            new Date()
          )
          .format("YYYY-MM-DD 00:00:00")
          .toString(),
        ],
        pagesize: 5,
        currentPage: 1,
        indexs: 0, // 催单索引值
        clickFramingchecked: false, // 开启自动刷单
        // productionCakeFlag: false, // 请先勾选蛋糕(批量生产)
        // volumnStampFlag: false, // 请先勾选蛋糕(批量打印)
        // volumnStorageFlag: false, // 请先勾选蛋糕（批量入库）
        productionSumFlag: false, // 弹窗Flag
        productionStartFlag: false, // 批量生产
        productionStampFlag: false, // 批量打印
        productionStorageFlag: false, // 批量入库
        productionQuery: {
          deptId: JSON.parse(window.localStorage.getItem("saber-areaId")).content,
          xmbzNo: '',
          mainWarehouse: '', // 总仓
          warehouseId: '', //分仓
          status: 0,
          deliveryStartTime: this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD 00:00:00")
            .toString(), //配送开始时间,
          deliveryEndTime: this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD 23:59:59")
            .toString(), //配送开始时间,
          goodsName: '', //产品名称
          goodsSpecs: '', // 产品磅数
          printingState: 0,// 打印状态
          // size: 10
        },
        productionrules: {
          // name: [
          //   { required: true, message: '请输入活动名称', trigger: 'blur' },
          //   { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          // ],
          // region: [
          //   { required: true, message: '请选择活动区域', trigger: 'change' }
          // ],
        },
        // statusList: '',// 状态
        statusList: [{
            dictKey: 0,
            dictValue: '全部'
          },
          {
            dictKey: 2,
            dictValue: '待生产'
          },
          {
            dictKey: 3,
            dictValue: '生产中'
          },
          {
            dictKey: 4,
            dictValue: '已入库'
          },
          {
            dictKey: 10,
            dictValue: '已退订'
          },
          {
            dictKey: 9,
            dictValue: '改期'
          }
        ],
        printingStateList: [
          {
            dictKey: 0,
            dictValue: '全部'
          },
          {
            dictKey: 1,
            dictValue: '未打印'
          },
          {
            dictKey: 2,
            dictValue: '已打印'
          },
        ],
        pickerOptions:{
          onPick: (obj) => {
            this.pickerMinDate = new Date(obj.minDate).getTime();
          },
          disabledDate:(time)=> {
            if (this.pickerMinDate) {
              const day1 =  31 * 24 * 3600 * 1000
              let maxTime = this.pickerMinDate + day1;
              let minTime = this.pickerMinDate - day1;
              return time.getTime() > maxTime || time.getTime()<minTime
            }
          }
        },
        // pickerOptions: {
        //   shortcuts: [{
        //     text: '最近一周',
        //     onClick(picker) {
        //       const end = new Date();
        //       const start = new Date();
        //       start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
        //       picker.$emit('pick', [start, end]);
        //     }
        //   }, {
        //     text: '最近一个月',
        //     onClick(picker) {
        //       const end = new Date();
        //       const start = new Date();
        //       start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
        //       picker.$emit('pick', [start, end]);
        //     }
        //   }, {
        //     text: '最近三个月',
        //     onClick(picker) {
        //       const end = new Date();
        //       const start = new Date();
        //       start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
        //       picker.$emit('pick', [start, end]);
        //     }
        //   }]
        // },
        startruleForm: { // 开始生产
          producer: '', // 制作人
          carver: '', // 裱花人
          packer: '', // 打包人
          orderIds: [], // 后台单号
          orderDetails: [{
            id: '',
            producer: '',
            carver: '',
            packer: ''
          }],
          orderDetailId: [], // 订单明细id
        },
        startruleForms: { // 开始生产
          orderIds: [], // 后台单号
          orderDetails: []
        },
        startrules: {
          producer: [{
            required: true,
            validator: validatePass,
            trigger: 'change'
          }],
          carver: [{
            required: true,
            validator: validatePass3,
            // message: '请输入裱花人',
            trigger: 'change'
          }],
          packer: [{
            required: true,
            validator: validatePass4,
            // message: '请输入打包人',
            trigger: 'change'
          }]
        },
        StampruleForm: {},
        // 总仓
        wareHouse: {
          parentId: JSON.parse(window.localStorage.getItem("saber-areaId")).content
        },
        getMainWarehouseList: [], //总仓列表
        abbrHouse: { // 分仓
          deptId: 3
        },
        getSeparateWarehouseList: [], //分仓列表
        getProductionOrderSummary: { // 今日生产数量(请求参数)
          deptId: JSON.parse(window.localStorage.getItem("saber-areaId")).content,
          deliveryStartTime: '',
          deliveryEndTime: '',
        },
        getProductionOrderSummaryList: '', // 今日生产数量列表
        cityLi: {
          roleId: 1
        },
        getProductionQueryPageList: '', // 查询列表
        batchStartProductionList: { //批量生产请求接口订单列表列表
          orderIds: [],
          orderDetails: []
        },
        orderWarehousingList: {
          orderId: 123,
          orderDetailId: 132
        },
        addOrderWarehousingLog: { // 新增入库记录列表
          orderId: 123,
          orderDetailId: 132,
          warehousingState: 0
        },
        StampStorageList: [], // 打印列表
        StorageRecordStartFlag: false, // 入库成功与否弹框
        StorageRecordList: [], // 获取入库记录请求列表
        StampStorageReturnList: '', //打印返回列表
        StorageRecordAbnormalList: '', // 获取入库记录正常、异常数量
        // StorageRecordAbnormalLogList: '', //  获取入库记录异常数量列表
        listProp: {
          deptId: JSON.parse(window.localStorage.getItem("saber-areaId")).content,
          // deptId: 4,
          status: 0,
          size: 100
        },
        abnormalOrderFlag: false, // 异常订单的flag
        getNotReadOrderNewsLogList: [], // 异常订单记录列表
        getProductionProcessList: [{
            "id": 285,
            "parentId": 284,
            "code": "production_process",
            "dictKey": 1,
            "dictValue": "继续生产",
            "sort": 1,
            "remark": "",
            "isDeleted": 0
          },
          {
            "id": 286,
            "parentId": 284,
            "code": "production_process",
            "dictKey": 2,
            "dictValue": "报损蛋糕",
            "sort": 2,
            "remark": "",
            "isDeleted": 0
          },
          {
            "id": 287,
            "parentId": 284,
            "code": "production_process",
            "dictKey": 3,
            "dictValue": "不生产",
            "sort": 3,
            "remark": "",
            "isDeleted": 0
          }
        ], // 生产中的蛋糕流程列表
        productionChoiceQuery: { // 生产部生产流程选择请求列表
          id: '',
          productionProcess: '',
          orderId: '',
          orderDetailId: '',
          // remarks: '',
          promoter: ''
        },
        total: 0,
        getNotReadOrderNewsLogQuery: {
          cityId: JSON.parse(window.localStorage.getItem("saber-areaId")).content,
          limit: 10,
          page: 1,
          size: 10,
          mainWarehouseId: '', // 总仓id
          warehouseId: '', // 分仓id
          productionProcess: '6',
          startTime: this.dayjs(
              new Date(new Date().getTime()-72*60*60*1000)
            )
            .format("YYYY-MM-DD"),
          endTime: this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD"),
        },
        AbnormalrecordListQuery: {
          cityId: JSON.parse(window.localStorage.getItem("saber-areaId")).content,
          limit: 10,
          page: 1,
          size: 10,
          productionProcess: '0',
          startTime: this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD"),
          endTime: this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD"),
        },
        // Abnormalrecordform: {
        //   cityId: JSON.parse(window.localStorage.getItem("saber-areaId")).content,
        //   limit: 10,
        //   page: 1,
        //   size: 10,
        //   productionProcess: 0,
        //   startTime: '',
        //   endTime: '',
        // },
        // closeOrderFlag: false, // 关闭接单是否选蛋糕规格的列表
        closeOrderlist: {
          // deptId: JSON.parse(window.localStorage.getItem("saber-areaId")).content,
          orderDetailIds: [],
          warehouseId: ''
        },
        getCloseOrderList: {
          cityId: '',
          warehouseId: '',
          page: 1,
          size: 10,
          limit: 10
        }, // 生产中异常订单订单操作按钮的显隐
        closeOrderListOpenFlag: false, // 接单关闭列表
        tableData: [], // 关闭接单列表数据
        getUpCloseOrderQuery: { // 开启接单列表
          goodsCloseIds: []
        },
        statusArray: [],
        clickfarmingTimer: null, // 开启接单定时器
        farmingTimer: null, // 异常列表定时器
        isQueryFlag: false, // 是否点击查询按钮，来判断开启接单应该怎么刷新数据
        cityId: '',
        tabs: [
          //标签数据
          {
            name: "异常订单列表"
          },
          {
            name: "异常订单记录"
          },
        ],
        Abnormalrecordtotal: 0,
        getAbnormalrecordList: [], //记录
        // CookieTemplateList: [{
        //   goodsName: '曲奇饼干曲奇饼干曲奇饼干曲奇饼干曲奇饼干曲奇饼干曲奇饼干曲奇饼干曲奇饼干',// 名称（35）
        //   material: '奶油、水、白砂糖、芒果泥、灭菌乳、咖啡酒（朗姆酒、咖啡豆、白砂糖、食用香料、焦糖色）、蓝莓、鸡蛋、干酪、果酱、樱桃、草莓、代可可脂巧克力制品、代可可脂巧克力、小麦粉、榴莲肉、大豆油、即溶咖啡、芒果、全脂乳粉、饼干、可可粉、黄油、食用玉米淀粉、葡萄糖、食用盐、食品添加剂[食用明胶、复配增稠剂（菊粉、羧甲基纤维素钠、麦芽糊精、果胶）、复配酸度调节剂（酒石酸氢钾、乳糖、食用淀粉、食用葡萄糖、单硬脂酸甘油酯、微晶纤维素）、果胶、复配膨松剂（焦磷酸二氢二钠、碳酸氢钠、碳酸钙、食用淀粉）]',// 配料表（240）
        //   netContent: '1900g',// 净含量（5）
        //   getNowTime: '',// 生产日期 （11）
        //   qualityGuaranteePeriod: '15天',// 保质期（5）
        //   processingMode: '热加工热加工热加工热', // 加工方式（10）
        //   goodsTypeName: '烘烤类糕点',// 产品类别（10）
        //   storageConditions: '常温密封保存',// 储存方式（10）
        //   eatways: '开袋即食',// 食用方法（10）
        //   manufacturer: '杭州市熊猫不走烘焙有限公司杭州市熊猫不走烘焙有限公司杭州市熊猫不走烘焙有限',// 生产商（36）
        //   address: '浙江省杭州市丽水数字大厦浙江省杭州市丽水数字大厦浙江省杭州市丽水数字大厦浙江省杭州市丽水数字大厦浙江省杭州市丽水数字大厦浙江省杭州市丽水数字大厦杭州市丽水数字',// 地址（75）
        //   contactInformation: '0757-8333379822',// 联系方式（15）
        //   licence: 'SC124440604005767676',// 食品生产许可证编号（20）
        //   standard: 'GB/T 20977',// 产品实行标准（12）
        //   Sensitizer: '含有麸质的谷物及制品蛋类及其制品大豆及其制品乳及乳制品含有麸质的谷物及制品蛋类及其制品大豆含有麸质的',// 致敏物提示（50）
        // }],
        timeValue: [], // 查询时间值
        timeValueFlag: false, // 查询时间是否大于31天标记
        tableDatatotal: 0,
        barnchWarehousesName: '全部',
        mainWarehouseNames:'全部',
        labelchecked: false, // 打印标签纸开关checked
        tradeNameRecord: [],// 商品名称历史记录列表
        tradeName: '',
      }
    },
    created() {
      window.addEventListener("keydown",this.keyupEnter);
    },
    watch: {
      // getNotReadOrderNewsLogList() {
      //   // console.log('0990909')
      //   this.protimer(); // 刷单
      // }
      'labelchecked'() {
        window.localStorage.setItem('labelchecked',this.labelchecked);
      },
      'closeOrderListOpenFlag'() {
        if(this.closeOrderListOpenFlag) {
          window.removeEventListener("keydown",this.keyupEnter);
        } else {
          window.addEventListener("keydown",this.keyupEnter);
        }
      },
      'productionStampFlag'() {
        if(this.productionStampFlag) {
          window.removeEventListener("keydown",this.keyupEnter);
        } else {
          window.addEventListener("keydown",this.keyupEnter);
        }
      },
      'abnormalOrderFlag'() {
        if(this.abnormalOrderFlag) {
          window.removeEventListener("keydown",this.keyupEnter);
        } else {
          window.addEventListener("keydown",this.keyupEnter);
        }
      }
    },
    mounted() {
      // getCakeProductionStateList().then(res => {
      //   console.log('res',res.data.data)
      // })
      window.clearInterval(this.clickfarmingTimer)
      this.getMinWareList();
      this.barnchWarehouses();
      // this.abmormalOrderRecord()
      setTimeout(() => {
        this.cityId = JSON.parse(window.localStorage.getItem("saber-areaId")).content
        this.getAbnormalList() // 异常订单记录
        this.getDeliveryTime()
        this.getProductionNumber()
      },1000)
      this.protimer();
      if(window.localStorage.getItem('labelchecked') !== null) {
        if(window.localStorage.getItem('labelchecked') !== undefined && window.localStorage.getItem('labelchecked') !== '') {
          this.labelchecked = JSON.parse(window.localStorage.getItem('labelchecked'));
        } else {
          this.labelchecked = false;
        }
      }
      // 产品名称搜索记录
      let tradeNameRecord = JSON.parse(window.localStorage.getItem('tradeNameRecord'));
      if(tradeNameRecord === null) {
        this.tradeNameRecord = [];
        window.localStorage.setItem('tradeNameRecord',JSON.stringify(this.tradeNameRecord));
      } else {
        if(tradeNameRecord.length == 0) {
          this.tradeNameRecord = [];
          window.localStorage.setItem('tradeNameRecord',JSON.stringify(this.tradeNameRecord));
        } else {
          this.tradeNameRecord = tradeNameRecord;
        }
      }
      window['ProsubmitForm'] = () => {
        this.submitForm()
      }
      window['ProPrintFlag'] = () => {
        this.$refs['procedureEdit'].StampStoragebtn = false;
        this.$refs['procedureEdit'].Ingredientsbtn = false;
      }
    },
    methods: {
      getMinWareList(){
        this.cityId = JSON.parse(window.localStorage.getItem("saber-areaId")).content
        // console.log('this.cityId',this.cityId)
        // 总仓
        this.wareHouse.parentId = this.cityId;
        getMainWarehouseListByRoleIdAll(this.wareHouse).then(res => {
          res.data.data.unshift({
            id: '',
            deptName: "全部"
          })
          this.getMainWarehouseList = res.data.data
          this.mainWarehouseIds = res.data.data[0].id;
          this.mainWarehouseNames = res.data.data[0].deptName;
          // this.productionQuery.mainWarehouse = res.data.data[0].deptName;

        })
      },
      //仓库地区ID选择事件
      getmainWarehouseIds(data) {
        if(this.productionQuery.mainWarehouse=='全部'){
          this.productionQuery.mainWarehouse=''
          this.mainWarehouseNames=''
           this.mainWarehouseIds =''
          this.barnchWarehouses();
          this.getNotReadOrderNewsLogQuery.mainWarehouseId = ''
        }else{
          this.productionQuery.mainWarehouse = data.label;
           this.mainWarehouseIds = data.value;
           this.mainWarehouseNames= data.label;
            this.barnchWarehouses();
          this.getNotReadOrderNewsLogQuery.mainWarehouseId = data.value;
        }

        // this.mainWarehouseIds = data.value;
        this.barnchWarehousesName='全部';
        this.productionQuery.warehouseId = "";
      },
      barnchWarehouses() {
          var saberareaIds = JSON.parse(localStorage.getItem("saber-areaId"));
          this.cityareaId = saberareaIds["content"];
          getSeparateWarehouseListByRoleIdAll({
            cityId: this.cityareaId,
            deptId: this.mainWarehouseIds == '' ? '' : this.mainWarehouseIds,
          }).then(response => {
            response.data.data.unshift({
              id: '',
              name: "全部"
            })
            this.getSeparateWarehouseList = response.data.data;
            this.mainWarehouseIds = response.data.data[0].id;
            this.barnchWarehousesName = response.data.data[0].name;
            this.productionQuery.warehouseId = response.data.data[0].id;

          });
      },
      getbarnchWarehouses(data) {
        this.productionQuery.warehouseId = data.value;
        this.barnchWarehousesName = data.label;
      },
      // 初始页currentPage、初始每页数据数pagesize和数据data
      handleSizeChange: function(size) {
        this.pagesize = size
      },
      handleCurrentChange: function(currentPage) {
        this.currentPage = currentPage
      },
      // 退订改期异常记录
      // abmormalOrderRecord() {
      //     // console.log('退订改期订单')
      //   getNotReadOrderNewsLog(this.getNotReadOrderNewsLogQuery).then(res => {
      //     // this.getNotReadOrderNewsLogList.forEach(() => {

      //     // })
      //     // console.log('退订改期订单')
      //     this.total = res.data.data.total
      //     console.log('this.total',this.total)
      //     if(res.data.data.rows.length > 0) {
      //       // console.log(this.getNotReadOrderNewsLogList,'退订改期订单')
      //       this.getNotReadOrderNewsLogList = res.data.data.rows
      //       // this.getProductionProcess()// 生产中的蛋糕按钮流程列表
      //       // this.getAbnormalList() // 异常订单记录
      //       this.abnormalOrderFlag = true
      //     }
      //   })
      // },
      // 计算时间差
      getNowTime() {
        let nowYear = new Date().getFullYear()
        let nowMonth = (new Date().getMonth() + 1) < 10 ? "0" + (new Date().getMonth() + 1) : (new Date().getMonth() +
          1);
        let nowDate = new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate();
        // let nowHours = new Date().getHours() < 10? "0" + new Date().getHours() : new Date().getHours();
        // let nowMinutes = new Date().getMinutes() < 10? "0" + new Date().getMinutes() : new Date().getMinutes();
        // console.log(e.currentTarget.dataset.time,nowYear + '-' + nowMonth + '-' + nowDate + ' ' + nowHours + ':' + nowMinutes)
        let nowTime = nowYear + '-' + nowMonth + '-' + nowDate + ' '
        // console.log('nowTime',nowTime,'nowTime')
        return nowTime
      },
      getProductionNumber() {
        // 今日生产数量汇总
        this.getProductionOrderSummary = { // 备款退订请求参数
          deptId: this.productionQuery.deptId,
          xmbzNo: this.productionQuery.xmbzNo,
          // mainWarehouse: this.productionQuery.mainWarehouse,
          mainWarehouse:this.mainWarehouseNames == '全部' ? '' : this.mainWarehouseNames,
          warehouseId: this.productionQuery.warehouseId,
          status: this.productionQuery.status,
          deliveryStartTime: this.productionQuery.deliveryStartTime,
          deliveryEndTime: this.productionQuery.deliveryEndTime,
          goodsName: this.productionQuery.goodsName,
          goodsSpecs: this.productionQuery.goodsSpecs
        }

        getProductionOrderSummary(this.getProductionOrderSummary).then(res => {
          this.getProductionOrderSummaryList = res.data.data;
          if(this.getProductionOrderSummary.mainWarehouse==''){
            this.productionQuery.mainWarehouse='全部'
            this.mainWarehouseNames='';
          }
          // console.log('00000000000')
        })
      },
      // 异常列表刷单
      protimer() {
        if(this.farmingTimer !== null) {
          window.clearInterval(this.farmingTimer)
        }
        this.farmingTimer = setInterval(() => {
          this.getAbnormalList()
        }, 30 * 1000)
      },
      getAbnormalList() {
        let disabledArray = [];
        // 异常订单记录
        this.getNotReadOrderNewsLogQuery.warehouseId = this.productionQuery.warehouseId
        getNotReadOrderNewsLog(this.getNotReadOrderNewsLogQuery).then(res => {
          this.total = res.data.data.total;
          this.getNotReadOrderNewsLogList = res.data.data.rows;
          if (res.data.data.rows.length > 0) {
            this.getNotReadOrderNewsLogList.forEach(item => {
              if (item.newsType == 2 && item.productionProcess == 6) {
                disabledArray.push(false);
              }
            })
            if (disabledArray.indexOf(false) > -1) {
              this.abnormalOrderFlag = true;// 异常列表Flag
            }
          } else {
            this.abnormalOrderFlag = false;// 异常列表Flag
          }
        })
        // console.log('disabled',disabled);
      },
      // 接单查询（当所需查询参数其中任何一项不为空）
      queryList() {
         // this.productionQuery.mainWarehouse = this.mainWarehouseNames == '全部' ? '' : this.mainWarehouseNames;
         this.productionQuery = { // 备款退订请求参数
                   deptId: this.productionQuery.deptId,
                   xmbzNo: this.productionQuery.xmbzNo,
                   // mainWarehouse: this.productionQuery.mainWarehouse,
                   mainWarehouse:this.mainWarehouseNames == '全部' ? '' : this.mainWarehouseNames,
                   warehouseId: this.productionQuery.warehouseId,
                   status: this.productionQuery.status,
                   deliveryStartTime: this.productionQuery.deliveryStartTime,
                   deliveryEndTime: this.productionQuery.deliveryEndTime,
                   goodsName: this.productionQuery.goodsName,
                   goodsSpecs: this.productionQuery.goodsSpecs
                 }
        getProductionQueryPage(this.productionQuery).then(res => {
          this.getProductionQueryPageList = res.data.data
          if(this.productionQuery.mainWarehouse==''){
            this.productionQuery.mainWarehouse='全部'
            this.mainWarehouseNames='';
          }
        })
      },
      // 查询中是否含有参数
      isQuery() {
        if (
          (this.productionQuery.xmbzNo !== '' ||
            this.productionQuery.mainWarehouse !== '' ||
            this.productionQuery.branchWarehouse !== '' ||
            this.productionQuery.deliveryStartTime !== '' ||
            this.productionQuery.deliveryEndTime !== '' ||
            this.productionQuery.goodsName !== '' ||
            this.productionQuery.goodsSpecs !== '') &&
          this.isQueryFlag == true
        ) {
          // console.log('其中一项含有',this.isQueryFlag)
          this.queryList()
        } else {
          this.isQueryFlag = false
          // console.log('全部不含有',this.isQueryFlag)
          this.$refs['procedureEdit'].getList()
        }
      },
      clickFraming(val) { // 刷单
        window.clearInterval(this.clickfarmingTimer)
        if (val == true) {
          // console.log('this.isQueryFlag',this.isQueryFlag)
          this.isQuery()
          this.clickfarmingTimer = setInterval(() => {
            this.isQuery()
          }, 60 * 1000)
        } else {
          window.clearInterval(this.clickfarmingTimer)
          // console.log('停止定时器')
        }
      },
      submitForm(formName) { // 查询
        this.productionQuery.page = this.$refs['procedureEdit'].currentPage = 1;
        this.getAbnormalList();
        let productionQuery = {
          deptId: this.productionQuery.deptId,
          xmbzNo: this.productionQuery.xmbzNo,
          // mainWarehouse: this.productionQuery.mainWarehouse,
          mainWarehouse:this.mainWarehouseNames == '全部' ? '' : this.mainWarehouseNames,
          warehouseId: this.productionQuery.warehouseId,
          status: this.productionQuery.status !== '' ? this.productionQuery.status : 0,
          deliveryStartTime: this.productionQuery.deliveryStartTime,
          deliveryEndTime: this.productionQuery.deliveryEndTime,
          goodsName: this.productionQuery.goodsName,
          goodsSpecs: this.productionQuery.goodsSpecs,
          printingState: this.productionQuery.printingState,
          page: this.productionQuery.page,
          size: this.productionQuery.size
        }
        if(this.tradeNameRecord.length < 8 && (this.productionQuery.goodsName !== '')) {
          this.tradeNameRecord.unshift({'value': this.productionQuery.goodsName});
          window.localStorage.setItem('tradeNameRecord',JSON.stringify(this.tradeNameRecord));
        } else if (this.tradeNameRecord.length >= 8 && (this.productionQuery.goodsName !== '')) {
          this.tradeNameRecord.unshift({'value': this.productionQuery.goodsName});
          this.tradeNameRecord = this.tradeNameRecord.slice(0,8);
          window.localStorage.setItem('tradeNameRecord',JSON.stringify(this.tradeNameRecord));
        }
        this.isgreaterThan(this.productionQuery.deliveryStartTime,this.productionQuery.deliveryEndTime)
        if(!this.timeValueFlag) {
          getProductionQueryPage(productionQuery).then(res => {
            // console.log(res.data);
            this.getProductionQueryPageList = res.data.data;
            if(this.productionQuery.mainWarehouse==''){
              this.productionQuery.mainWarehouse='全部'
              this.mainWarehouseNames='';
            }
          })
          this.isQueryFlag = true;
          this.getProductionNumber();
        }
        this.$refs['procedureEdit'].StampStoragebtn = false;
        this.$refs['procedureEdit'].Ingredientsbtn = false;
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      volumnProduction() { // 批量生产
        let oldProcedure = [];
        if(this.$refs['procedureEdit'].checkedAllFlag == false) {
          oldProcedure = [];
        } else {
          oldProcedure = this.$refs['procedureEdit'].getMessage();
        }
        // console.log('this.$refs.getMessage()',oldProcedure)
        this.statusArray = [];
        let productionorderIdList = [];
        let orderNumArr = [];
        let orderNumObj = {};
        orderNumObj = {
          id: '',
          producer: '',
          carver: '',
          packer: ''
        }
        if (oldProcedure.length > 0) {
          // this.productionCakeFlag = false;
          oldProcedure.forEach((item, index) => {
            this.statusArray.push(item.productionState)
            orderNumObj = {
              id: oldProcedure[index].id,
              producer: '未填写',
              carver: '未填写',
              packer: '未填写'
            }
            productionorderIdList.push(item.orderId)
            orderNumArr.push(orderNumObj)
          })
          this.startruleForm.orderIds = productionorderIdList
          this.startruleForm.orderDetails = orderNumArr
          this.startruleForms.orderDetails = this.startruleForm.orderDetails
          this.startruleForms.orderIds = this.startruleForm.orderIds
          // console.log(this.startruleForms)
          if (this.statusArray.indexOf(0) > -1 || this.statusArray.indexOf(3) > -1 || this.statusArray.indexOf(4) > -1 ||
            this.statusArray.indexOf(9) > -1 || this.statusArray.indexOf(10) > -1) {
            this.$message({
              message: '点击批量生产前，请选择待生产的蛋糕',
              type: 'warning'
            });
            this.statusArray = []
          } else {
            batchStartProduction(this.startruleForms).then(res => {
              if (res.data.code == 200) {
                this.$notify({
                  title: '批量生产成功',
                  message: '请您耐心等待',
                  type: 'success'
                })
                this.$refs.procedureEdit.checkedAll = false
                this.getProductionNumber()
                this.$refs['procedureEdit'].getList();
                setTimeout(() => {
                  // this.productionSumFlag = false
                  this.statusArray = []
                  // this.productionStartFlag = false;
                }, 1 * 1000);
              }
            })
            // this.productionSumFlag = true;
            // this.productionStartFlag = true;
          }
        } else {
          this.$message({
            message: '您还未选择蛋糕，请先勾选蛋糕',
            type: 'warning'
          });
          // this.productionCakeFlag = true;
        }
      },
      startSubmitForm(formName) { // 批量生产确认按钮
        this.startruleForm.orderDetails.forEach(item => {
          item.producer = this.startruleForm.producer
          item.carver = this.startruleForm.carver
          item.packer = this.startruleForm.packer
        })
        this.startruleForms.orderDetails = this.startruleForm.orderDetails
        this.startruleForms.orderIds = this.startruleForm.orderIds
        this.$refs[formName].validate((valid) => {
          if (valid) {
            let startruleForms = this.startruleForms
            batchStartProduction(startruleForms).then(res => {
              if (res.data.code == 200) {
                this.$notify({
                  title: '批量生产成功',
                  message: '请您耐心等待',
                  type: 'success'
                })
                this.$refs[formName].resetFields();
                // this.getList();
                this.$refs.procedureEdit.checkedAll = false;
                this.getProductionNumber()
                this.$refs['procedureEdit'].getList();
                setTimeout(() => {
                  this.productionSumFlag = false
                  this.statusArray = []
                  this.productionStartFlag = false;
                }, 1 * 1000);
              }
            })
          } else {
            return false;
          }
        });
      },
      startResetForm(formName) { // 批量生产取消按钮
        this.$refs[formName].resetFields();
        this.productionSumFlag = false
        this.productionStartFlag = false;
      },
      volumnStamp() { // 批量打印
        window.localStorage.setItem('proPathFlag',this.$route.path);
        let oldProcedure = [];
        if(this.$refs['procedureEdit'].checkedAllFlag == false) {
          oldProcedure = [];
        } else {
          oldProcedure = this.$refs['procedureEdit'].getMessage();
        }
        this.$refs.procedureEdit.WarehousingLogStatus = []
        // console.log(oldProcedure,'批量打印',this.$refs.procedureEdit.WarehousingLogStatus)
        if (oldProcedure.length > 0) {
          // this.volumnStampFlag = false;
          let Stamplist = []
          oldProcedure.forEach((item) => {
            Stamplist.push(item.id)
            this.$refs.procedureEdit.WarehousingLogStatus.push(Number(item.productionState))
          })
          this.StampStorageList = Stamplist;
          // console.log(this.$refs.procedureEdit.WarehousingLogStatus)
          if (this.$refs.procedureEdit.WarehousingLogStatus.indexOf(2) > -1 || this.$refs.procedureEdit.WarehousingLogStatus.indexOf(0) > -1 || this.$refs.procedureEdit.WarehousingLogStatus
            .indexOf(9) > -1 || this.$refs.procedureEdit.WarehousingLogStatus.indexOf(10) > -1) {
            this.$message({
              message: '打印失败，只能打印生产中和已入库的蛋糕',
              type: 'warning'
            });
            this.$refs.procedureEdit.WarehousingLogStatus = []
          } else {
            this.productionSumFlag = true;
            this.productionStampFlag = true;
          }
        } else {
          this.$message({
            message: '您还未选择蛋糕，请先选择蛋糕',
            type: 'warning'
          });
          // this.volumnStampFlag = true;
        }
      },
      StampSubmitForm(e, formName) { // 打印确认按钮
        let formInline = {
          type: 1,
          key: '[1,2]',
          userId: JSON.parse(window.localStorage.getItem("saber-userInfo")).content.account
        }
        query(formInline).then(res => {
          if(res.data.msg == '执行成功') {
            console.log('res.data.data[0].value',res.data.data.length)
            if(res.data.data.length == 0) {
              this.$message.warning("请到系统模块中的打印机设置中添加打印机");
              this.$refs['procedureEdit'].StampStoragebtn = false;
            } else if (res.data.data.length > 0) {
              res.data.data[0].value = `${res.data.data[0].value}`;
              formInline.value = JSON.parse(res.data.data[0].value);
              formInline.print01 = formInline.value[0];
              formInline.print02 = formInline.value[1];
              console.log(res.data.data[0].value,'000','formInline.value',formInline.print01);
              this.$refs[formName].validate((valid) => {
                if (valid) {
                  let _this = this;
                  orderPrinting(this.StampStorageList).then(res => {
                    if (res.data.code == 200) {
                      this.StampStorageReturnList = res.data.data
                      // console.log(this.StampStorageReturnList,'StampStorageList')
                      setTimeout(() => {
                        this.productionSumFlag = false;
                        this.productionStampFlag = false;
                        const LODOP = getLodop()
                        // console.log('LODOP',LODOP)
                        if (LODOP) {
                          var strBodyStyle = '<style>'
                          strBodyStyle +=
                            '.tableList table { border-top: 0; border-left: 0; border-collapse:collapse; border-spacing:0;height: 200px;}'
                          // strBodyStyle += 'caption { line-height:2; }'
                          strBodyStyle +=
                            'td { border-right: 0;width: 130px; border-bottom: 0; padding:2px 3px; font-size:11px;}'
                          strBodyStyle += '</style>' //设置打印样式
                          var strFormHtml = strBodyStyle + '<body>' + document.getElementById('Printform').innerHTML +
                            '</body>' //获取打印内容
                          LODOP.PRINT_INIT('') //初始化
                          // LODOP.SET_PRINTER_INDEX("NPI46C2BB (HP LaserJet M1536dnf MFP)"); // 增加，需删除
                          LODOP.SET_PRINT_PAGESIZE(0, '101.6mm', '0mm', 'USER')
                          // LODOP.SET_PRINT_PAGESIZE(2, 0, 0, 'A4') //设置横向
                          LODOP.ADD_PRINT_HTM('1%', '1%', '98%', '98%', strFormHtml) //设置打印内容
                          // console.log('strFormHtml',strFormHtml)
                          // LODOP.SET_PREVIEW_WINDOW(2, 0, 0, 800, 600, 0) //设置预览窗口模式和大小
                          let printFlag = true;// 判断传参是否有空
                          let printArray = [];// 判断传参是否有空
                          CLODOP.On_Return=function(TaskID,value){
                            var stResult = LODOP.GET_VALUE("PRINT_STATUS_ID",value)
                            var stResultText = LODOP.GET_VALUE("PRINT_STATUS_TEXT",value)
                            // console.log('value',value,stResult,stResultText)
                            if(value) {
                              if(_this.StampStorageList.length > 0) {
                                _this.StampStorageList.forEach(item => {
                                  if((item == undefined) || (item == '') || (item == null)) printArray.push(false);
                                })
                              } else {
                                printArray.push(false);
                              }
                              if(printArray.indexOf(false) > -1) {
                                printFlag = false;
                                _this.$message.warning('未获取到打印数据，请重新选择');
                                setTimeout(() => {
                                  _this.StampStoragebtn = false;
                                  _this.$refs['procedureEdit'].getList();
                                },1000);
                              } else {
                                printFlag = true;
                              }
                              if(printFlag) {
                                orderPrintingFrequency(_this.StampStorageList).then(res => {
                                  if (res.data.code == 200) {
                                    // res.data.data.forEach((resitem, resindex) => {
                                    //   res.data.data[resindex].productionState = this.$refs.procedureEdit.WarehousingLogStatus[
                                    //     resindex]
                                    // })
                                    _this.$notify({
                                      title: '打印成功',
                                      message: '请您耐心等待',
                                      type: 'success'
                                    })
                                    _this.$refs.procedureEdit.checkedAll = false
                                    _this.$refs['procedureEdit'].getList();
                                    _this.$refs.procedureEdit.WarehousingLogStatus = []
                                  }
                                })
                              }
                            } else {
                              _this.$message.warning('打印失败，请检查是否安装好驱动和已经连接打印机');
                              setTimeout(() => {
                                _this.StampStoragebtn = false;
                                _this.$refs['procedureEdit'].getList();
                              },1000);
                            }
                          }
                          // LODOP.PREVIEW()
                          LODOP.SET_PRINT_MODE(formInline.print01,true);//这个语句设置网络共享打印机
                          LODOP.SET_PRINTER_INDEX(formInline.print01,true); // 增加，需删除
                          console.log(LODOP.SET_PRINTER_INDEX(formInline.print01),LODOP.SET_PRINTER_INDEX(formInline.print01,true),'LODOP.SET_PRINTER_INDEX(`${formInline.print01}`)')
                          if(LODOP.SET_PRINTER_INDEX(formInline.print01)) {
                            if(printFlag) LODOP.PRINT(); // 增加，需删除
                          }
                          this.$refs.procedureEdit.checkedAll = false
                          this.$refs['procedureEdit'].getList();
                          this.$refs.procedureEdit.WarehousingLogStatus = []
                        }
                      }, 2 * 1000);
                      this.$refs['procedureEdit'].getList();
                      this.productionSumFlag = false;
                      this.productionStampFlag = false;
                    }
                  })
                } else {
                  return false;
                }
              });
            }
          }
        })
      },
      StampResetForm() { // 打印取消按钮
        this.productionSumFlag = false
        this.productionStampFlag = false
      },
      // volumnStorage() { // 批量入库
      //   let oldProcedure = this.$refs['procedureEdit'].getMessage()
      //   // console.log(oldProcedure)
      //   if(oldProcedure.length > 0) {
      //     this.volumnStorageFlag = false;
      //     let orderNumArr = []
      //     let orderNumObj = {}
      //     orderNumObj = { orderId: '', orderDetailId: '' }
      //     oldProcedure.forEach((item,index) => {
      //       orderNumObj = { orderId: oldProcedure[index].orderId, orderDetailId: oldProcedure[index].id }
      //       orderNumArr.push(orderNumObj)
      //     })
      //     this.orderWarehousingList = orderNumArr
      //     this.orderWarehousingList.forEach(item => {
      //       // console.log(item)
      //       let Storagelist = []
      //       Storagelist.push(item.orderDetailId)
      //       this.StorageRecordList = Storagelist
      //       this.addOrderWarehousingLog = item
      //       orderWarehousing(item).then(res => {
      //         if(res.data.code == 200) {
      //           this.$notify({
      //             title: '批量入库成功',
      //             message: '请您耐心等待',
      //             type: 'success'
      //           })
      //         }
      //       }).catch(error => {
      //         console.log(error)
      //         this.addOrderWarehousingLog.warehousingState = 2
      //         addOrderWarehousingLog(this.addOrderWarehousingLog).then(res => {
      //           if(res.data.code == 200) {
      //             getOrderWarehousingLogList(this.StorageRecordList).then(res => {
      //               if(res.data.code) {
      //                 this.StorageRecordStartFlag = true
      //                 this.StorageRecordAbnormalList = res.data.data
      //               }
      //             })
      //           }
      //         })
      //       })
      //     })
      //   } else {
      //     this.volumnStorageFlag = true;
      //   }
      // },
      acTiveArrStringFun(obj) {
        var arr = [];
        if (obj != null && obj.length != 0) {
          for (var i = 0; i < obj.length; i++) {
            arr.push(obj[i]);
          }
        }
        return arr.toString();
      },
      getKindFlag() {
        let oldProcedure = this.$refs['procedureEdit'].getMessage()
        if (oldProcedure > 0) {
          // this.productionCakeFlag = false;
          // this.volumnStampFlag = false;
          // this.volumnStorageFlag = false;
        }
      },
      StorageRecordSubmitForm() { // 入库信息显示确定按钮
        this.abnormalOrderFlag = false
      },
      // StorageRecordResetForm() { // 入库信息显示取消按钮  getNotReadOrderNewsLogList
      //   this.StorageRecordStartFlag = false
      // }
      handleTabs(item) {
        this.indexs = item;
        if (this.indexs == 0) {
          this.getAbnormalList() // 异常订单记录
        } else {
          this.Time=[
            this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD 00:00:00")
            .toString(),
            this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD 00:00:00")
            .toString(),

          ],
          // this.AbnormalrecordListQuery.startTime = this.dayjs(
          //     item[0]
          //   )
          //   .format("YYYY-MM-DD")
          //   .toString();
          // this.AbnormalrecordListQuery.endTime = this.dayjs(
          //     item[1]
          //   )
          //   .format("YYYY-MM-DD")
          //   .toString();
           this.AbnormalrecordListQuery.page = 1;
          getNotReadOrderNewsLog(this.AbnormalrecordListQuery).then(res => {
            this.Abnormalrecordtotal = res.data.data.total;
            this.getAbnormalrecordList = res.data.data.rows;
          })

        }

      },
      handleFilter(item) {
        if (item) {
          this.AbnormalrecordListQuery.startTime = this.dayjs(
              item[0]
            )
            .format("YYYY-MM-DD")
            .toString();
          this.AbnormalrecordListQuery.endTime = this.dayjs(
              item[1]
            )
            .format("YYYY-MM-DD")
            .toString();

        }
        var time1 = Date.parse(this.AbnormalrecordListQuery.startTime);
        var time2 = Date.parse(this.AbnormalrecordListQuery.endTime);
        //讲两个时间相减，求出相隔的天数
        var dayCount = Math.abs(time2 - time1) / 1000 / 60 / 60 / 24;
        if (dayCount > 31) {
          this.$message({
            showClose: true,
            message: "时间间隔不可超过31天",
            type: "warning"
          });
        } else {
          this.getAbnormalrecordLists();
          // getNotReadOrderNewsLog(this.AbnormalrecordListQuery).then(res => {
          //   this.Abnormalrecordtotal = res.data.data.total;
          //   this.getAbnormalrecordList = res.data.data.rows;
          // })
        }
      },
      abnormalClick() { // 异常订单
        this.abnormalOrderFlag = true;
        this.getAbnormalList() // 异常订单记录
      },
      getAbnormalrecordLists(){

          getNotReadOrderNewsLog(this.AbnormalrecordListQuery).then(res => {
            this.Abnormalrecordtotal = res.data.data.total;
            this.getAbnormalrecordList = res.data.data.rows;
          })
      },
      productionSelect(index, row, dictKey) {
        // console.log(row, 'e.currentTarget.dataset')
        this.productionChoiceQuery.id = row.id
        this.productionChoiceQuery.orderId = row.orderId
        this.productionChoiceQuery.orderDetailId = row.orderDetailId
        this.productionChoiceQuery.productionProcess = dictKey
        this.productionChoiceQuery.promoter = row.promoter
        let remarks = row.remarks
        if(dictKey == 1) {
          this.$confirm('操作【继续生产】，请在3小时内点击【入库】', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            showClose: false,// 右上角关闭按钮
            showCancelButton: false,// 取消按钮
            closeOnClickModal: false,// 点击遮罩关闭
            closeOnPressEscape: false,// 按下 ESC 键关闭
          }).then(() => {
            this.queryChoice(remarks);
            confirmProductionToWarehousingLog({orderId: row.orderId}).then(res => {
              console.log('res.data.data',res.data.data);
            })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            });          
          });
        } else {
          this.queryChoice(remarks);
        }
      },
      queryChoice(remarks) {
        if (remarks === '退订') {
          productionChoice(this.productionChoiceQuery).then(res => {
            if (res.data.code == 200) {
              // this.abmormalOrderRecord()
              // console.log('退订',res.data)
              // console.log('productionprocess',res.data)
              // this.getProductionProcessFlag = false
              this.$notify({
                title: '操作成功',
                message: '请您耐心等待',
                type: 'success'
              })
              this.getAbnormalList() // 异常订单记录
            }
          })
        } else if (remarks === '退款') {
          // console.log(this.productionChoiceQuery)
          refundChoice(this.productionChoiceQuery).then(res => {
            // console.log('退款',res.data)
            if (res.data.code == 200) {
              this.$notify({
                title: '操作成功',
                message: '请您耐心等待',
                type: 'success'
              })
              this.getAbnormalList() // 异常订单记录
              // this.getProductionProcessFlag = false
            }
          })
        }
      },
      volumnNormalOrder() {
        this.abnormalOrderFlag = true;
      },
      // 关闭接单
      closeOrder() {
        let status = []
        let orderDetailIds = []
        let oldProcedure = [];
        if(this.$refs['procedureEdit'].checkedAllFlag == false) {
          oldProcedure = [];
        } else {
          oldProcedure = this.$refs['procedureEdit'].getMessage();
        }
        if (oldProcedure.length > 0) {
          // this.closeOrderFlag = false;
          // let warehouseIds = []
          // console.log('oldProcedure',oldProcedure)
          oldProcedure.forEach((item) => {
            orderDetailIds.push(item.id)
            status.push(item.productionState)
            this.closeOrderlist.warehouseId = item.warehouseId
          })
          this.closeOrderlist.orderDetailIds = orderDetailIds
          // this.closeOrderlist.warehouseIds = warehouseIds
          // this.startruleForm.orderIds = productionorderIdList
          // console.log(this.closeOrderlist, 'this.closeOrderlist',status.indexOf(2))
          if (status.indexOf(12) == -1 && status.indexOf(3) == -1 && status.indexOf(4) == -1 && status.indexOf(9) == -1 &&
            status.indexOf(10) == -1 && status.indexOf(6) == -1 && status.indexOf(2) > -1) {
            // console.log('没有')
            // console.log(this.closeOrderlist.orderDetailIds, 'this.closeOrderlist.orderDetailIds')
            let _this = this;
            window.removeEventListener("keydown",this.keyupEnter);
            this.$confirm('<div">1.关闭后，列表里此规格蛋糕全部下架，是否确认关闭?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><br/><div>2.关闭后，此蛋糕对应的订单会消失，需要客服重新确认！</div>', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              dangerouslyUseHTMLString: true,
              center: true,
              type: 'warning',
              beforeClose(action,instance,done){
                if(action=="confirm"){
                  instance.$refs['confirm'].$el.onclick=function(e){
                    e=e||window.event
                    // console.log(e.detail)
                    if(e.detail!=0){
                      done()
                    }
                  }
                }else{
                  window.addEventListener("keydown",_this.keyupEnter);
                  done()
                }
            }
            }).then(() => {
              closeOrder(this.closeOrderlist).then(res => {
                if (res.data.code == 200) {
                  this.$message({
                    type: 'success',
                    message: '关闭成功!'
                  });
                  // this.$refs[formName].resetFields();
                  // this.getList();
                  // this.$refs.procedureEdit.checkedAll = false
                  this.getProductionNumber()
                  this.$refs['procedureEdit'].getList();
                  window.addEventListener("keydown",_this.keyupEnter);
                }
              })
            }).catch(() => {
              window.addEventListener("keydown",this.keyupEnter);
              this.$message({
                type: 'info',
                message: '已取消关闭蛋糕'
              });
              this.closeOrderlist.orderDetailIds = [];
              this.closeOrderlist.warehouseId = '';
            });
          } else {
            this.$message({
              message: '所选蛋糕中含有除待生产状态以外的蛋糕，请重新选择蛋糕',
              type: 'warning'
            })
          }
        } else {
          this.$message({
            message: '您还未选择蛋糕，请先选择蛋糕',
            type: 'warning'
          });
          // this.closeOrderFlag = true;
        }
      },
      // 接单关闭列表
      closeOrderListOpen() {
        this.closeOrderListOpenFlag = true
        // console.log(this.getCloseOrderList.warehouseId)
        // if(this.getCloseOrderList.warehouseId !== '') {
        this.getCloseOrderList.cityId = JSON.parse(window.localStorage.getItem("saber-areaId")).content
        // console.log('getCloseOrderList',this.getCloseOrderList)
        getCloseOrderList(this.getCloseOrderList).then(res => {
          if (res.data.code == 200) {
            this.tableDatatotal = res.data.data.total
            // console.log('关闭接单列表',res.data.data)
            this.tableData = res.data.data.rows
          }
        })
        // } else if (this.getCloseOrderList.warehouseId == '') {
        //   this.$message({
        //     type: 'warning',
        //     message: '你还未选择分仓，请先选择分仓!'
        //   });
        // }
      },
      // 获取请求接单关闭列表的分仓id
      getwarehouseId(e) {
        this.getCloseOrderList.warehouseId = e.currentTarget.dataset.id
        // console.log(e.currentTarget.dataset)
      },
      // 开启接单
      toggleSelectionOpen() {
        if (this.getUpCloseOrderQuery.goodsCloseIds !== '') {
          getUpCloseOrder(this.getUpCloseOrderQuery).then(res => {
            if (res.data.code == 200) {
              this.$notify({
                title: '操作成功',
                message: '请您耐心等待',
                type: 'success'
              })
              this.closeOrderListOpenFlag = false;
              this.getCloseOrderList.page = 1;
              // this.$refs[formName].resetFields();
              // this.getList();
              // this.$refs.procedureEdit.checkedAll = false
              this.$refs['procedureEdit'].getList();
              // console.log('开启接单',res.data.data)
            }
          })
        }
      },
      // 关闭接单列表
      handleSelectionChange(val) {
        this.getUpCloseOrderQuery.goodsCloseIds = [];
        // this.multipleSelection = val;
        val.forEach(item => {
          this.getUpCloseOrderQuery.goodsCloseIds.push(item.id)
        })
        console.log(this.getUpCloseOrderQuery.goodsCloseIds,'val')
      },
      handletoggleSelectionOpen() {
        this.closeOrderListOpenFlag = false;
      },
      // 根据id查询分仓
    //   getwareHouseOpen(val) {
    //     if(this.productionQuery.mainWarehouse == '' || this.productionQuery.mainWarehouse === null) {
    //       this.getNotReadOrderNewsLogQuery.mainWarehouseId = '';
    //     } else {
    //       this.getNotReadOrderNewsLogQuery.mainWarehouseId = val.value;
    //     }
    //     if (val) {
    //       this.productionQuery.mainWarehouse = val.label
    //       this.abbrHouse.deptId = val.value
    //       getSeparateWarehouseListByRoleIdAll(this.abbrHouse).then(res => {
    //         let result = res.data.data
    //         // console.log('res.data.data',res.data.data)
    //         if (result.length > 0) {
    //           result.forEach(item => {
    //             this.getSeparateWarehouseList = result;
    //             // console.log('this.listMessage.channer',this.listMessage.channer)
    //             if (this.productionQuery.mainWarehouse !== undefined) {
    //               if (item.id == this.productionQuery.mainWarehouse) {
    //                 // console.log('有',item)
    //                 this.getSeparateWarehouseList = result;
    //               } else {
    //                 // console.log('没有',item)
    //                 this.getSeparateWarehouseList = result;
    //                 this.productionQuery.warehouseId = ''
    //               }
    //             }
    //           })
    //         } else {
    //           this.getSeparateWarehouseList = result;
    //           this.productionQuery.warehouseId = '';
    //         }
    //         // this.getSeparateWarehouseList = res.data.data
    //       })
    //     } else if (val == null) {
    //       this.productionQuery.warehouseId = '';
    //     }
    //   },

      // cookieStamp() {
      //   const LODOP = getLodop()
      //   if (LODOP) {
      //     // console.log('res.data.data',res.data.data)
      //     LODOP.PRINT_INIT('') //初始化
      //     LODOP.SET_PRINTER_INDEX("POSTEK C168/200s",true); // 增加，需删除
      //     // LODOP.SET_PRINTER_INDEX("NPI46C2BB (HP LaserJet M1536dnf MFP)"); // 增加，需删除
      //     LODOP.SET_PRINT_PAGESIZE(0,'101.6mm',0,'USER')
      //     // LODOP.SET_PRINT_PAGESIZE(2, 0, 0, 'A4') //设置横向
      //     LODOP.ADD_PRINT_HTM('1%', '1%', '98%', '98%', document.getElementById('CookieTemplate').innerHTML) //设置打印内容
      //     // console.log('strFormHtml',strFormHtml)
      //     LODOP.SET_PREVIEW_WINDOW(2, 0, 0, 800, 600, 0) //设置预览窗口模式和大小
      //     LODOP.PREVIEW()
      //     // if(LODOP.SET_PRINTER_INDEX("NPI46C2BB(HP LaserJet M1536dnf MFP)")) LODOP.PRINT(); // 增加，需删除
      //     // if(LODOP.SET_PRINTER_INDEX("POSTEK C168/200s",true)) LODOP.PRINT(); // 增加，需删除
      //     this.$notify({
      //       title: '打印成功',
      //       message: '请您耐心等待',
      //       type: 'success'
      //     })
      //   }
      // },
      // 设置默认查询日期
      getDeliveryTime() {
        //前一天设定的日期时间
        let d = new Date
        let year1,month1,day1
        [year1,month1,day1] = [d.getFullYear(),d.getMonth(),d.getDate()];
        let date1 = new Date(year1,month1,day1,0);
        let nowMonth1 = (new Date().getMonth() + 1) < 10 ? "0" + (new Date().getMonth() + 1) : (new Date().getMonth() +
          1);
        let nowDate1 = new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate();
        let deliveryStartTime = date1.getFullYear() + '-' + nowMonth1 + '-' + nowDate1 + ' ' + '00:00:00';
        this.timeValue.unshift(date1);
        this.productionQuery.deliveryStartTime = deliveryStartTime;
        //当前设定的日期时间
        let date2 = new Date(year1, month1, day1,23,59,59);
        let deliveryEndTime = date1.getFullYear() + '-' + nowMonth1 + '-' + nowDate1 + ' ' + '23:59:59';
        this.timeValue.push(date2);
        this.productionQuery.deliveryEndTime = deliveryEndTime;
      },
      changeTime(val) {
        this.productionQuery.deliveryStartTime = val[0] + ':00';
        this.productionQuery.deliveryEndTime = val[1] + ':59';
      },
      // 判断是否大于31天
      isgreaterThan(time1,time2) {
        var data1 = Date.parse(time1.replace(/-/g,"/"));
        var data2 = Date.parse(time2.replace(/-/g,"/"));
        var datadiff = data2-data1;
        var time = 31*24*60*60*1000;
        if(time1.length>0 && time2.length>0){
          if(datadiff<0||datadiff>time){
            // console.log("开始时间应小于结束时间并且间隔小于31天，请检查!",data1,data2,datadiff);
            this.$message.warning("时间间隔不可超过31天");
            return this.timeValueFlag = true;
          } else {
            return this.timeValueFlag = false;
          }
        }
      },
      // 回车事件
      keyupEnter(){
        if(window.event.keyCode == 13 ){
          // this.$refs['typeRef'].blur();
          this.submitForm();// 查询事件
        }
      },
      // 选择框回车失焦
      selectBlur(e) {
        if(e.keyCode == 13) {
          this.$refs['mainWarehouseRef'].blur();
          this.$refs['barnchWarehousesRef'].blur();
          this.$refs['statusRef'].blur();
          this.$refs['printingRef'].blur();
          e.returnValue = false;
        }
      },
      // 静止输入空格
      keydown(event) {
        if(event.keyCode == 32) {
          event.returnValue = false;
        }
        if(event.keyCode == 13) {
          this.$refs['goodsNameRef'].blur();
          event.returnValue = false;
        }
      },
      querySearch(queryString, cb) {
        this.tradeNameRecord.forEach((item,index) => {
          if(typeof(item) == 'string') this.tradeNameRecord[index] = { 'value' : item };
        })
        window.localStorage.setItem('tradeNameRecord',JSON.stringify(this.tradeNameRecord));
        let restaurants = this.tradeNameRecord;
        var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
        // 调用 callback 返回建议列表的数据
        cb(results);
      },
      createFilter(queryString) {
        return (restaurant) => {
          return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      },
    },
    destroyed() {
      window.removeEventListener("keydown",this.keyupEnter);
      // window.clearInterval(this.farmingTimer)
      // clearTimeout(this.farmingTimer);
    },
    //如果页面有keep-alive缓存功能，这个函数会触发
    activated() {
      window.addEventListener("keydown",this.keyupEnter);
    },
    deactivated() {
      window.removeEventListener("keydown",this.keyupEnter);
    }
  }
</script>

<style lang="scss">
  .tablist {
    display: flex;
    margin-bottom: 20px;

    .name {
      padding: 0 20px;
      text-align: center;
      color: #000;
      font-size: 20px;
      line-height: 40px;
      cursor: pointer;

      &.active {
        font-size: 20px;
        color: #43a0ff;
        border-bottom: 1px solid #43a0ff;
      }
    }
  }

  .Abnormalrecord-inline {
    .el-form-item__content {
      line-height: 32px !important;
    }
  }

  .productionCommon {
    display: flex;
  }

  .productionCommonCopy {
    display: flex;
    flex-wrap: wrap;
  }

  .production-button {
    margin-top: 30px;
  }

  .production-message {
    font-size: 17px
  }

  .production-number {
    font-size: 20px
  }

  .statistics {
    .production-bigbutton {
      margin-right: 20px;
      color: #FFF;
      background-color: #409EFF;
      border-color: #409EFF;
      padding: 12px 20px;
      font-size: 14px;
      border-radius: 4px;
      text-align: center;
      font-weight: 500;
      display: inline-block;
      line-height: 1;
      white-space: nowrap;

      &.success {
        background-color: #67c23a;
        border-color: #67c23a;
      }

      &.infostatistics {
        background-color: #909399;
        border-color: #909399;
      }

    }

  }

  .CoummonFlag {
    margin-top: 5px;
    font-size: 12px;
    color: red;
  }

  .el-scrollbar {
    padding-bottom: 15px;
  }

  .StorageRecording-abnormal {
    display: flex;
    justify-content: space-around;
    line-height: 3;
    margin-bottom: 10px;
  }

  .StorageRecording-abnormal span {
    text-align: center;
  }

  .StorageRecord-message {
    color: red;
  }

  .StorageRecord-title {
    color: #454649;
    font-size: 17px;
  }

  .cakeName {
    width: 20%;
    text-align: center;
  }

  .page-component__scroll .el-scrollbar__bar.is-vertical {
    opacity: 0;
  }

  .page-component__scroll .el-scrollbar__wrap {
    overflow-x: hidden;
  }

  #pdf-viewer #content {
    height: 350px !important;
    position: fixed;
    width: 100%;
    z-index: 1;
  }

  .ordermain {
    font-size: 10px;
    line-height: .8;
  }

  .StorageRecord-operation {
    width: 40%;
    text-align: center;
    display: flex;
    justify-content: center;
  }

  .StorageRecord-order {
    width: 20%;
    text-align: center;
  }

  .StorageRecord-record {
    width: 10%;
    text-align: center;
  }

  .StorageRecord-schedule {
    width: 10%;
    text-align: center;
  }

  .branchWareHouse .el-select-dropdown__item {
    padding: 0;
  }
  .el-date-range-picker .el-picker-panel__footer .el-button--text span {
    display: none;
  }
</style>
